<script setup>
import { onMounted, ref } from 'vue';


// 1.创建一个ref对象
const myInpRef = ref(null)
onMounted(() => {
  myInpRef.value.focus()
})

const btnRef = ref(null)
console.log(btnRef.value);
onMounted(() => {
  console.log(btnRef.value);
})

const clikeMe = () => {
  myInpRef.value.focus()
}

</script>

<template>
  <div>
    <input ref="myInpRef" type="text">
    <button ref="btnRef" @click="clikeMe">点我</button>
  </div>
</template>

<style scoped></style>